'use strict';

var _regenerator = require('babel-runtime/regenerator');

var _regenerator2 = _interopRequireDefault(_regenerator);

var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');

var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

/**
 * 选定股票的绑定事件
 * @param string stock 股票代码
 */
var selectedFn = function () {
    var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(stock) {
        return _regenerator2.default.wrap(function _callee$(_context) {
            while (1) {
                switch (_context.prev = _context.next) {
                    case 0:
                        $('#view_stock_input').blur();
                        //await hqQuote.request(condition.render, stock, '');

                    case 1:
                    case 'end':
                        return _context.stop();
                }
            }
        }, _callee, this);
    }));

    return function selectedFn(_x) {
        return _ref.apply(this, arguments);
    };
}();
//时间戳转换成 01-02 20：10


function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

//@charset "utf-8"
/*限制字数*/
function mCutStr(str, len, str2) {

    if (str2 == '') {
        var str3 = '';
    } else {
        var str3 = str2 || '...';
    }
    if (str == '') {
        return '';
    } else {
        var str_length = 0; //实际长度
        var str_len = 0;
        str_cut = new String();
        str_len = str.length;
        for (var i = 0; i < str_len; i++) {

            var a = str.charAt(i);
            str_length++;
            //中文的情况多加1
            if (escape(a).length > 4) {
                //中文字符的长度经编码之后大于4
                str_length++;
            }
            str_cut = str_cut.concat(a);
            if (str_length <= len && (i == str_len - 1 || i == str_len - 2)) {
                return str;
            }
            if (str_length >= len && i < str_len - 2) {
                str_cut = str_cut.concat(str3);
                return str_cut;
            }
            if (str_length >= len && i < str_len - 1) {
                str_cut = str_cut.concat(str3);
                return str_cut;
            }
        }
    }
}
/*只能输入数字和小数点*/
function clearNoNum(obj) {
    //先把非数字的都替换掉，除了数字和点(.)
    obj.value = obj.value.replace(/[^\d.]/g, "");
    //必须保证第一个为数字而不是点(.)
    obj.value = obj.value.replace(/^\./g, "");
    //保证只有出现一个点而没有多个点
    obj.value = obj.value.replace(/\.{2,}/g, ".");
    //保证点只出现一次，而不能出现两次以上
    obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
}
/*点击关闭和取消，关闭当前自己的主窗口*/
$(".hd-close, .cancel, #way_sure").on('click', function () {
    $(this).parent().parent().hide();
    if ($(".mask").css("display") != "block") {
        $(".mask").show();
    } else {
        $(".mask").hide();
    }
});
//点击取消统计
$("#cancelPro").click(function () {
    var external = new ThsExternal();
    external.closeWindow();
    TaNumber.cancelPro();
});
/*是否显示预警声音*/
$('.sound').live('click', function () {
    var sounds = $(".sound").find(".c-on");
    if (sounds.css("display") != "inline-block") {
        $("#soundid").hide();
    } else {
        $("#soundid").show();
    }
});
//按键精灵中的input下的提示
function weiNull() {
    if ($("#view_stock_input").val() == '') {
        $('.tip-stock').show();
    } else {
        $('.tip-stock').hide();
    }
}
//获取location.url中的某一个字段值
function getUrlParam(item) {
    var value = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)", "i"));
    return value ? value[1] : value;
}function userDate(uData) {
    var myDate = new Date(uData * 1000);
    var nowDate = new Date();
    var nMonth = nowDate.getMonth() + 1;
    var nDay = nowDate.getDate();
    var year = myDate.getFullYear();
    var month = myDate.getMonth() + 1;
    var day = myDate.getDate();
    var hours = myDate.getHours();
    var minutes = myDate.getMinutes();
    if (nMonth == month && nDay == day) {
        if (hours < 10) {
            hours = '0' + hours;
        }
        if (minutes < 10) {
            minutes = '0' + minutes;
        }
        return '今天' + ' ' + hours + ':' + minutes;
    } else {
        if (month < 10) {
            month = '0' + month;
        }
        if (day < 10) {
            day = '0' + day;
        }
        if (hours < 10) {
            hours = '0' + hours;
        }
        if (minutes < 10) {
            minutes = '0' + minutes;
        }
        return month + '-' + day + ' ' + hours + ':' + minutes;
    }
}
//闪动
var shake = function shake(element, className, times) {
    var i = 0,
        t = false,
        o = element.attr('class'),
        c = "",
        times = times || 2;
    if (t) return;
    t = setInterval(function () {
        i++;
        c = i % 2 ? o + ' ' + className : o;
        element.attr('class', c);
        if (i == 2 * times) {
            clearInterval(t);
            element.removeCless(className);
        }
    }, 100);
};
Array.prototype.delNull = function (from, to) {
    from = from || '';
    to = to || null;
    var arr = this;
    var len = arr.length;
    for (var i = 0; i < len; i++) {
        if (arr[i] == from) {
            // arr.splice(i, 1);
            if (to == null) {
                arr.splice(i, 1);
            } else {
                arr.splice(i, 1, to);
            }
        }
    }
    return arr;
};
function modeAdd() {
    var mode = new Array();
    mode.push($("#keep_monitor").hasClass("c-on") ? 1 : 0);
    mode.push($("#show_pop").hasClass("c-on") ? 1 : 0);
    //mode.push(1);
    if ($("#show_sounds").hasClass("c-on")) {
        mode.push(1);
        mode.push(1);
        mode.push($("#soundid").val());
    } else {
        mode.push(0);
        mode.push(1);
    }
    mode.push($("#keep_iphone").hasClass("c-on") ? 1 : 0);
    mode = mode.join(',');
}
//点击通知到手机
$(".spread, #call_appid").click((0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2() {
    var util;
    return _regenerator2.default.wrap(function _callee2$(_context2) {
        while (1) {
            switch (_context2.prev = _context2.next) {
                case 0:
                    TaNumber.spreadId();
                    util = new ThsUtil();
                    _context2.next = 4;
                    return util.openAppWebDlg('http://sp.10jqka.com.cn/sms/downloadapp/');

                case 4:
                case 'end':
                    return _context2.stop();
            }
        }
    }, _callee2, this);
})));